using UnityEngine;

public class UIToolBar : MonoBehaviour
{
	private UIToolBarItem[] _items;

	private void Start()
	{
		_items = base.gameObject.GetComponentsInChildren<UIToolBarItem>();
		for (int i = 0; i < _items.Length; i++)
		{
			UIToolBarItem uIToolBarItem = _items[i];
			Item item = ItemMgr.instance.GetItem(uIToolBarItem.itemId);
			uIToolBarItem.txtNumber.text = ((item == null) ? "0" : (item.count + string.Empty));
			if (item == null || item.count <= 0)
			{
				uIToolBarItem.enableBtn = false;
			}
		}
	}

	private void Update()
	{
	}

	public void EnableAllItem()
	{
		for (int i = 0; i < _items.Length; i++)
		{
			Item item = ItemMgr.instance.GetItem(_items[i].itemId);
			if (item != null && item.count > 0)
			{
				_items[i].enableBtn = true;
			}
			else
			{
				_items[i].enableBtn = false;
			}
		}
	}
}
